package com.oms.core.service.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.oms.core.dao.impl.GeneralDAO;
import com.oms.core.service.IGeneralService;

/**
 * IGeneralService的实现
 * @author Loong_Mit
 * @date Sep 1, 2012 5:44:02 PM
 */

public class GeneralService<E, PK extends Serializable> implements IGeneralService<E, PK> {

	protected final Log log = LogFactory.getLog(getClass());
	
	protected GeneralDAO<E, PK> dao;
	
	public void setDao(GeneralDAO<E, PK> dao) {
		this.dao = dao;
	}
	
	@Override
	public void batchDelete(final List<PK> list) {
		this.dao.batchDelete(list);
	}

	@Override
	public void batchInsert(final List<E> list) {
		this.dao.batchInsert(list);
	}

	@Override
	public void batchUpdate(final List<E> list) {
		this.dao.batchUpdate(list);
	}

	@Override
	public int count() {
		return this.dao.count();
	}

	@Override
	public int delete(Serializable primaryKey) {
		return this.delete(primaryKey);
	}

	@Override
	public void delete(String sqlId, Object parameters) {
		this.dao.delete(sqlId, parameters);
	}

	@Override
	public E get(Serializable primaryKey) {
		return (E) this.dao.get(primaryKey);
	}

	@Override
	public List<E> getAll() {
		return this.dao.getAll();
	}

	@Override
	public void insert(Object entity) {
		this.insert(entity);
	}

	@Override
	public List<E> queryForList(String sqlId) {
		return this.dao.queryForList(sqlId);
	}

	@Override
	public List<E> queryForList(String sqlId, Object parameters) {
		return this.dao.queryForList(sqlId, parameters);
	}

	@Override
	public List<E> queryForList(String sqlId, String sql) {
		return this.dao.queryForList(sqlId, sql);
	}

	@Override
	public List<E> queryForList(String sqlId, Map<String, Object> map) {
		return this.dao.queryForList(sqlId, map);
	}

	@Override
	public E queryForObject(String sqlId, Object parameters) {
		return (E) this.dao.queryForObject(sqlId, parameters);
	}

	@Override
	public int update(Object entity) {
		return this.dao.update(entity);
	}

	@Override
	public void update(String sqlId, Object parameters) {
		this.dao.update(sqlId, parameters);
	}
}